package experiment;

//添加员工操作
public class AddOperation implements IOperation{
    @Override
    public void work(EmployeeList employeeList) {
        System.out.println("对员工进行添加");
        System.out.println("请输入想要添加的员工的姓名：");
        String name = scanner.next();
        if(employeeList.isEmployeeContains(name)){
            System.err.println("该员工已经存在");
            return;
        }
        System.out.println("请输入员工编号：");
        String coding = scanner.next();
        System.out.println("请输入员工性别：");
        String sex = scanner.next();
        System.out.println("请输入员工的出生年月：");
        String birth = scanner.next();
        System.out.println("请输入员工所属部门的编号：");
        String dCoding = scanner.next();
        System.out.println("请输入员工所属部门的名称：");
        String dName = scanner.next();
        Department department = new Department(dCoding,dName);
        Employee employee = new Employee(coding,name,sex,birth,department);
        employeeList.addEmployee(employee);
        System.out.println("添加员工成功！");
    }
}
